package com.bruce.li.controller;

import com.bruce.li.service.SkuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
@RequestMapping("/goods")
public class SkuController {

    @Autowired
    SkuService skuService;

    @PostMapping("/init/{index}")
    public void init(@PathVariable("index")String index, HttpServletResponse response){
        try {
            boolean skuByPage = skuService.findSkuByPage(index);
            response.setContentType("text/html;charset=utf-8");
            response.getWriter().write("<h1>初始化完成</h1>");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
